using System;
using System.Collections.Generic;
using System.Linq;

namespace Catchbase.TestTools
{
    public class Subject<T>
    {
        private readonly Lazy<T> _instance;

        public Subject(IEnumerable<object> injections)
        {
            _instance = new Lazy<T>(() => CreateInstance(injections));
        }

        public T Instance
        {
            get { return _instance.Value; }
        }

        private static T CreateInstance(IEnumerable<Object> injections)
        {
            return typeof (T).CreateInstance<T>(injections.ToArray());
        }
    }
}